import request from '../../../components/Request';

/**
 * 根据机构名称查询机构列表
 * @returns {Promise<*>}
 */
export async function listOrgByName(pageNo, pageSize, type, name) {
  let result = await request.post({
    url: './org/listOrgByName.do',
    data: { pageNo: pageNo, pageSize: pageSize, type: type,    name: name },
  });
  return result.data;
}

/**
 * 查询机构类型字典
 * @returns {Promise<*>}
 */
export async function listOrgType() {
  let result = await request.post({ url: './dict/getDict.do', data: { key: 'orgType' } });
  return result.data;
}

/**
 * 保存机构信息
 * @param org 机构信息
 * @returns {Promise<*>}
 */
export async function saveOrg(org) {
  let result = await request.post({ url: './org/saveOrg.do', data: org });
  return result.data;
}

/**
 * 删除机构
 * @param org 机构
 * @returns {Promise<void>}
 */
export async function deleteOrg(org) {
  let pOrg = { id: org.id, cascade: org.cascade, parentId: org.parentId };
  return await request.post({ url: './org/deleteOrg.do', data: pOrg });
}
